<?php
session_start();
//print_r($_SESSION['ss_user']);exit;
if(isset($_SESSION['ss_user']))
{
	$user_info = $_SESSION['ss_user'];
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<!--<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>-->
<link type="text/css" href="ui/jquery.ui.css" rel="stylesheet"/>
<script type="text/javascript" src="ui/jquery.ui.min.js"></script>
<style type="text/css">
	#dialog-form label{
		font-size: 12px;
	}
	#dialog-form input{
		width: 172px;
		font-size: 12px;
		height: 25px;
	}
	.box_content{
		width: 300px;
		border: 1px solid;
		background-color: #D9EEF0;
	}
</style>
<title>Gift Code</title>
</head>

<body>
<div id="dialog-form" title="Đăng nhập">
	<table width="100%" border="0">
    <form name="login" action="" method="post">
    	<tr>
        	<td width="40%"><label>Tên đăng nhập </label></td>
            <td width="60%"><input id="username" type="text" class="text ui-widget-content ui-corner-all"/></td>
        </tr>
        <tr>
        	<td width="40%"><label>Mật khẩu </label></td>
            <td width="60%"><input id="password" type="password" class="text ui-widget-content ui-corner-all"/></td>
        </tr>     
    </form>
   	</table>
</div>
	<div class="box_content">  
    	<table>
        <?php
			if(isset($_SESSION['ss_user']))
			{
		?>
        	<tr>
            	<td>Tên đăng nhập</td>
                <td class="sv_lst"><input type="text" readonly="readonly" value="<?=$user_info->UserName?>"/></td>
            </tr>
            <tr>
                <td colspan="2" class="but_nhan"><input align="middle" type="button" value="Nhận" id="nhan_giftcode"/></td>
            </tr>
            <tr>
            	<td colspan="2"><span id="giftcode"></span></td>
            </tr>
           <?php
           	}
			?>
        </table>
        <script type="text/javascript">
			
        	$(document).ready(function() {
				
				function Login()
				{
					var username = $("#username").val();
					var password = $("#password").val();
					//alert(username + password);
					
				}
				
				$( "#dialog-form" ).dialog({
					autoOpen: false,
					height: 250,
					width: 350,
					modal: true,
					buttons: {
						Ok: function() {
							//alert('You\'re just click Ok!');
							//$(this).dialog("close");
							Login();
						}
					}
        		});
				//server list
      			$.ajax({
					 url: "serverlist.php", 
					 dataType: "text",
					 type: 'POST', 
					 data: "", 
					 success: function(data){
						 $(".sv_lst").html(data);
						 return;
					 }
      			});
				
				$('#nhan_giftcode').click(function(){
					var session_username = '';
					//$("#giftcode").html('Đang xử lý ...');
					if(session_username != '')
					{
						$( "#dialog-form" ).dialog( "open" );
					}
					else
					{
						$.ajax({
							 url: "getGiftCode.php", 
							 dataType: "text",
							 type: 'POST', 
							 data: "", 
							 success: function(giftcode){
								 $("#giftcode").html('Gift code của bạn: '+giftcode);
								 return;
							 }
						});
					}
				});
			});
        </script>
    </div>
</body>
</html>
